package ly.jobdu;

import java.util.Scanner;

public class Q1002Grading {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			String[] str = scanner.nextLine().split(" ");
			float p = (float) Integer.parseInt(str[0]);
			float t = (float) Integer.parseInt(str[1]);
			float g1 = (float) Integer.parseInt(str[2]);
			float g2 = (float) Integer.parseInt(str[3]);
			float g3 = (float) Integer.parseInt(str[4]);
			float gj = (float) Integer.parseInt(str[5]);
			grading(p, t, g1, g2, g3, gj);
		}
	}

	public static void grading(float p, float t, float g1, float g2, float g3, float gj) {
		float score = 0;
		if (Math.abs(g1 - g2) <= t) {
			score = (g1 + g2) / 2;
		} else {
			if (Math.abs(g3 - g1) <= t && Math.abs(g3 - g2) > t) {
				score = (g3 + g1) / 2;
			} else if (Math.abs(g3 - g1) > t && Math.abs(g3 - g2) <= t) {
				score = (g3 + g2) / 2;
			} else if (Math.abs(g3 - g2) <= t && Math.abs(g3 - g1) <= t) {
				score = findMax(g1, g2, g3);
			} else if (Math.abs(g3 - g1) > t && Math.abs(g3 - g2) > t) {
				score = gj;
			}
		}
		System.out.println(score);
	}

	public static float findMax(float g1, float g2, float g3) {
		float max = 0;
		if (g1 >= max) {
			max = g1;
		}
		if (g2 >= max) {
			max = g2;
		}
		if (g3 >= max) {
			max = g3;
		}
		return max;
	}
}
